//
//  Style1TableViewCell.m
//  PiPiPineapple
//
//  Created by 李晓东 on 17/11/7.
//  Copyright © 2017年 PeanutXu. All rights reserved.
//

#import "Style1TableViewCell.h"
#import "Tools.h"

@interface Style1TableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *redBallsView;
@property (weak, nonatomic) IBOutlet UILabel *blueBallView;
@property (weak, nonatomic) IBOutlet UILabel *acView;
@property (weak, nonatomic) IBOutlet UILabel *resultView;

@end

@implementation Style1TableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)showData:(DoubleChromosphere *)doubleChromosphere{
    NSArray *redBallsArray = doubleChromosphere.returnRedBall;
    NSString *acValueStr = doubleChromosphere.returnACValue;
    NSString *nextSomeBody = doubleChromosphere.returnNextSomeBody;
    
    NSString *redBallsStr = [redBallsArray componentsJoinedByString:@" "];
    NSString *someBody = doubleChromosphere.returnSomebody;
    
    if (nextSomeBody != nil) {
        // 获取 somebody 所在的位置,设置 attributeString 的 color
        NSRange someBodyInBalls = [redBallsStr rangeOfString:nextSomeBody];
        NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc]initWithString:redBallsStr];
        [attrStr addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:someBodyInBalls];
        [attrStr addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleSingle) range:someBodyInBalls];
        _redBallsView.attributedText = attrStr;
    } else {
        _redBallsView.text = [redBallsArray componentsJoinedByString:@" "];
    }
    
    _blueBallView.text = doubleChromosphere.returnBlueBall;
    _acView.text = someBody;
    _resultView.text = nextSomeBody;
    _resultView.textColor = [UIColor colorWithRed:255 / 255 green:112 / 255 blue:124 / 255 alpha:1];
}

@end
